<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //0转化为boolean类型，结果是false
    var num = 0;
    console.log(!!num);

    //NaN转化为boolean类型，结果也是false
    var notNum = NaN;
    console.log(!!notNum);

    //除了0和NaN以外的其他数字转化为boolean类型，结果都是true
    var num1 = 123;
    var num2 = -1;
    console.log(!!num1,!!num2);

    //undefined和null转化为boolean类型，结果都是false
    console.log(!!undefined);
    console.log(!!null);

    //字符串类型向boolean类型转化，除了空字符串""为false，其他的都是true
    var str = "";      //false
    var spaceStr = " ";//true
    var str1 = "hello";//true
    console.log(!!str);
    console.log(!!spaceStr);
    console.log(!!str1);

    var str2 = "hello js";
    var b1 = Boolean(str2);
</script>
</html>